home *** CD-ROM | disk | FTP | other *** search
- #ifndef _DTOBASE_HPP
- #define _DTOBASE_HPP
-
- /*************************************************************************
- *
- * DTObject -- Base Design-Time object
- *
- * DTObject is an abstract base class. Do not add any data members or
- * non-pure-virtual member functions.
- *
- * NOTE: if you add methods to DTObject, keep DTUObject synchronized!
- *
- *************************************************************************/
-
- #include "mtdef.hpp"
-
- class MetaObject;
- class FormEdit;
- class DTFormEditBase;
- class WStringList;
- class MMStyle;
- class MMProperty;
- class MMEvent;
- class MTPropertyDialog;
- class OleEventDialog;
- class MTIPropertyList;
- class MTIEventList;
- class DTUserFunctionVect;
- class DTCodeBlockList;
- class DTCodeBlockListList;
- class DTIInterface;
- class SaveSource;
- class SaveBlock;
- class DTCodeBlockBase;
- class ostream;
- struct DTObjectImp;
-
-
- #undef GetForm
- #if defined( _UNICODE )
- #define GetForm GetFormW
- #define SetForm SetFormW
- #else
- #define GetForm GetFormA
- #define SetForm SetFormA
- #endif
-
- #define VEXPORT virtual // don't override these
-
- typedef WInt DT_TextifyV;
- typedef WLong MMFileFragment;
- typedef WLong MMCodeGeneration;
- struct MMFileGenerationParms;
- struct MMCodeGenerationParms;
- class MMFDXPropertyVect;
-
- class METAEXPORTCLASSDEF DTObject : public WObject
- {
- public:
- virtual WBool operator== ( const DTObject & ) const = 0;
-
- public:
-
- /*************************************************************
- * Position
- *************************************************************/
-
- //
- // Rectangle
- //
- // The pixel-based position of the object; optionally, absolute
- // to the desktop.
-
- virtual void DTGetRectangle( WRect & r,
- WBool abs = FALSE ) const = 0;
- virtual void DTSetRectangle( const WRect & r,
- WBool abs = FALSE ) = 0;
-
- //
- // ClientRectangle
- //
- // Get the client rectangle. This is mainly used for DTForms.
-
- virtual void DTGetClientRectangle( WRect & r ) const = 0;
-
- //
- // RCRectangle
- //
- // The rectangle to use in the .rc file (still in pixel though).
- // This differs for WComboBox, which gives a .rc file rectangle
- // of the correct height instead of the design time height.
-
- virtual void DTGetRCRectangle( WRect & r ) const = 0;
-
- //
- // PixelsToDLU / DLUToPixels
- //
- // Map between pixels and dialog units (DLU).
-
- virtual WRect DTMapPixelsToDLU( const WRect & pix ) const = 0;
- virtual WRect DTMapDLUToPixels( const WRect & dlu ) const = 0;
-
- //
- // BringToTop
- //
- // Bring the object to the top of the Z- order
-
- virtual void DTBringToTop() = 0;
-
- //
- // Repaint
- //
- // Invalidate an object and cause it to be repainted
-
- virtual void DTRepaint( WRect * rect=NULL ) = 0;
-
- //
- // GenFileFragment
- //
- // Generate a file-level fragment of code.
-
- virtual void GenFileFragment( MMFileFragment fg, WStringList &,
- MMFileGenerationParms * parms ) const = 0;
-
- //
- // GenerateCode [new]
- //
- // Generate a fragment of code for a component.
- // The "cg" parameter indicates which scrap of code to generate.
-
- virtual void GenerateCode( MMCodeGeneration, ostream &, MMCodeGenerationParms & ) = 0;
-
- //
- // RequiredIncludes
- //
- // Fill in a list of required include files.
-
- virtual void GetRequiredIncludes( WStringList & includes ) const = 0;
-
- //
- // RequiredBaseClasses
- //
- // Fill in a list of required base classes to add to the form
-
- virtual void GetRequiredBaseClasses( WStringList & bases ) const = 0;
-
- /*************************************************************
- * Common Behaviour
- *************************************************************/
-
- //
- // Meta
- //
- // The Meta- object instance that is associated
- // with this DT- object
-
- VEXPORT const MetaObject * GetMeta() const = 0;
- VEXPORT void SetMeta( const MetaObject * ) = 0;
-
- //
- // Reference Card Meta
- // The Meta-object that is used to provide reference
- // card information. The default implentation returns GetMeta()
-
- VEXPORT const MetaObject * GetRefCardMeta() const = 0;
-
- //
- // Name
- //
- // The variable used in the user's code to represent this
- // object (eg. cb_1). Although there is a default implementation,
- // you may wish to override this to perform an action when the
- // name changes (eg. change names of all child objects).
-
- virtual void DTSetName( const WString & name ) = 0;
- virtual WString DTGetName() const = 0;
-
- //
- // ClassName
- //
- // This returns the class name of the form containing the object.
- // If the object has a class (i.e. it is a form), then it returns
- // the form name, not the containing name.
-
- virtual WString DTGetClassName() const = 0;
-
- //
- // ClassDefinition
- //
- // The class name used to implement a component in code.
- // This lets the user specify a different class than the
- // default.
-
- virtual void SetClassDefinition( const WString & ) = 0;
- virtual WString GetClassDefinition() const = 0;
-
- //
- // ClassIncludes
- //
- // Extra header files this compnonent requires (specified
- // by the user. For use with ClassDefinition.
-
- virtual void SetClassIncludes( const WString & ) = 0;
- virtual WString GetClassIncludes() const = 0;
-
- //
- // WImplementation
- //
- // Each DT- object must have an associated WObject that
- // represents it on the design-time form. This is not
- // required to be a WWindow-derived class, but that is the
- // case that has been tested most -- only WOleObjects are
- // an exception.
-
- VEXPORT WObject * GetWImplementation() const = 0;
- VEXPORT void SetWImplementation( WObject * wobj,
- WBool deleteOld=TRUE ) = 0;
-
- //
- // ConcreteInstance
- //
- // Return the concrete instance (the aggregated object)
-
- virtual const DTObject *GetConcreteImplementation() const = 0;
- virtual DTObject * GetConcreteImplementation() = 0;
-
- //
- // Window
- //
- // If there is a WWindow implementing the design-time
- // behaviour of the object, get and return it. Otherwise,
- // NULL (as for WOleObject).
-
- VEXPORT WWindow * GetWindow() const = 0;
-
-
- //
- // DTGetParent
- //
- // The parent window if there is a window.
-
- VEXPORT WWindow * DTGetParent() const = 0;
-
- //
- // ResourceID
- //
- // The id of the control in the .res file
-
- VEXPORT void SetResourceID( long id ) = 0;
- VEXPORT long GetResourceID() const = 0;
-
- //
- // TabIndex
- //
- // Tabbing order of control. Controls are emitted into
- // the resource file in tab index order.
-
- VEXPORT void SetTabIndex( long idx ) = 0;
- VEXPORT long GetTabIndex() const = 0;
-
-
- //
- // CodeBlockList
- //
- // A list of events associated with the object.
- //
- // RemoveEvent - remove a single event
- //
-
- VEXPORT const DTCodeBlockList & GetCodeBlockList() const = 0;
- VEXPORT DTCodeBlockList & GetCodeBlockList() = 0;
-
- VEXPORT WInt GetAllCodeBlockLists( DTCodeBlockListList & ) = 0;
-
- //
- // RemoveEvent
- //
- // Remove a code block from the list and remove any
- // other pointers to it (ie. from object inspector).
-
- VEXPORT DTCodeBlockBase * RemoveEvent( DTCodeBlockBase * ) = 0;
-
- //
- // FindEvent
- //
- // Find a code block that has already been added to
- // this object.
-
- VEXPORT DTCodeBlockBase * FindEvent( const char * ) const = 0;
-
- //
- // AllowEvent
- //
- // Allow the given event to be included in the event inpector
- // for this object.
-
- VEXPORT WBool AllowEvent( const MMEvent * ) const = 0;
-
- //
- // UserFunctionVect
- // A vector of user functions associated with the object.
- //
-
- VEXPORT const DTUserFunctionVect & GetUserFunctionVect() const = 0;
- VEXPORT DTUserFunctionVect & GetUserFunctionVect() = 0;
- VEXPORT void AddUserFunction( DTCodeBlockBase * ) = 0;
- VEXPORT void RemoveUserFunction( DTCodeBlockBase * ) = 0;
- VEXPORT DTCodeBlockBase * FindUserFunction( const char * ) = 0;
-
- //
- // CMCodeBlock
- //
- // Special class code blocks
- //
- VEXPORT DTCodeBlockBase * GetCMCodeBlock( WULong b ) const = 0;
- VEXPORT void SetCMCodeBlock( WULong b, DTCodeBlockBase * ) = 0;
-
- //
- // Form, DTForm
- //
- // The FormEdit associated with this object; the first
- // form is only useful from within Optima code; the second,
- // mainly from CompDLL. SetForm is called by Optima when
- // it instantiates the object.
-
- VEXPORT FormEdit * GetForm() const = 0;
- VEXPORT DTFormEditBase *GetDTForm() const = 0;
- VEXPORT void SetForm( DTFormEditBase * ) = 0;
-
- //
- // Child
- //
- // The DTObject Children for this DTObject. DTObjects
- // may now own other DTObjects.
-
- VEXPORT int GetChildCount() const = 0;
- VEXPORT DTObject * GetChild( int index ) const = 0;
- VEXPORT WBool AddChild( DTObject *, int after = -1 ) = 0;
- VEXPORT WBool RemoveChild( DTObject * ) = 0;
- VEXPORT DTObject * GetParent() const = 0;
-
- //
- // Style
- //
- // The Windows style property of the associated Window.
- // This doesn't necessarily match GetWindow()->GetStyle()
- // because some styles are deferred until run-time (such
- // as WSVisible).
-
- VEXPORT WStyle GetStyle() const = 0;
- VEXPORT WBool SetStyle( WStyle stl, WBool clone=FALSE ) = 0;
-
- //
- // DefaultStyle
- //
- // The style with which new instances are created. Default
- // implementation returns GetWindow()->GetDefaultStyle().
-
- virtual WStyle GetDefaultStyle() const = 0;
-
- //
- // ExtendedStyle
- //
- // The ExtendedStyle property of the window nature.
-
- virtual WStyle GetExtendedStyle() const = 0;
- virtual WBool SetExtendedStyle( WStyle style, WBool clone=FALSE ) = 0;
-
- //
- // DefaultExtendedStyle
- //
- // See DefaultStyle
-
- virtual WStyle GetDefaultExtendedStyle() const = 0;
-
- //
- // InternalStyle
- //
- // The styles that are stored internally.
-
- virtual void SetInternalStyle( WStyle s, WStyle ex ) = 0;
-
- //
- // Visible
- //
- // The object is currently visible.
-
- virtual WBool GetVisible() = 0;
- virtual WBool SetVisible( WBool visible ) = 0;
-
-
- //
- // Create
- //
- // Call Create on the windowed object.
- //
- virtual WBool Create( WWindow * parent, const WRect & r,
- const WChar * text, WStyle style,
- WStyle exStyle, void * data = NULL,
- WBool isLoading = FALSE ) = 0;
-
- //
- // NonVisual
- //
- // NonVisual objects are represented by a picture box at
- // design time -- eg. WTimer, WMessageBox, WFileDialog.
-
- VEXPORT WBool GetNonVisual() const = 0;
-
- // DTInfo
- //
- // Each object can have information that is not handled by
- // the general framework. For instance, listboxes store their
- // lines separately. HasDTInfo should return true if you want
- // to store object-specific information, then the SaveDTInfo
- // and LoadDTInfo functions will be called.
-
- virtual WBool HasDTInfo() = 0;
- virtual WBool SaveDTInfo( SaveSource & ) = 0;
- virtual WBool LoadDTInfo( SaveBlock *, WBool beforeCreate ) = 0;
-
- //
- // CreateEventPopupMenu
- //
- // Popupulate a popup menu with the events that are deemed
- // useful ("hot" events) as well as events with code. There
- // is a default behaviour which is overriden for Ole objects.
-
- virtual WBool CreateEventPopupMenu( WPopupMenu * popup ) = 0;
-
- //
- // IsResizeable
- //
- // IsResizeable allows non-visual objects and Ole objects to
- // deny resizing (can change after created
-
- virtual WBool GetIsResizeable() = 0;
-
- //
- // IsMoveable
- //
- // IsMoveable allows objects to deny being moved
- // for example if they are participating in a layout manager
- // or if they are a tab control page.
-
- virtual WBool GetIsMoveable() = 0;
-
-
- //
- // Hollow
- //
- // GroupBoxes are treated as "Hollow" controls in that when
- // they are moved, contained controls are also moved. Also,
- // hollow controls are not active except for a border around
- // the outside. HollowRect is the rectangle in the center
- // that doesn't activate the object.
-
- virtual WBool GetIsHollow() = 0; // groupbox
- virtual WRect GetHollowRect() = 0; // interior of groupbox
-
- //
- // DTPopupMenu
- // The popup menu associated with a WWindow. NOT the
- // popup menu that shows up at design-time.
- // [ITB:06/4] expect this will move to DTW.
-
- VEXPORT WBool SetDTPopupMenu( DTObject * ) = 0;
- VEXPORT DTObject * GetDTPopupMenu() const = 0;
-
- //
- // AmendPopup
- //
- // Override this function to modify the design-time context
- // popup. "before" is true before the popup is displayed,
- // false afterwards. Make sure you clean up any menu items
- // you add or they will remain for other objects as well.
- //
- virtual void AmendPopup( WPopupMenu *, WBool before ) = 0;
-
- //
- // IsValidChild
- //
- // Returns true if obj is allowed as a child of this
- // DTObject. errMsg is filled in with details about
- // why it isn't allowed.
- virtual WBool IsValidChild(
- const MetaObject *obj,
- WString &errMsg ) const = 0;
-
- //
- // IsValidContainer
- //
- // Returns true if obj is allowed as a container for this
- // DTObject. errMsg is filled in with details about
- // about why it isn't allowed.
- virtual WBool IsValidContainer(
- const DTObject *obj,
- WString &errMsg ) const = 0;
-
- //
- // SetEventHandler
- //
- // Set an event handler on the W-Implementation object.
-
- virtual WBool DTSetEventHandler( WEventID id,
- WObject * object,
- WEventHandler handler,
- void *userdata=NULL ) = 0;
-
- //
- // RemoveEventHandler
- //
- // Remove an event handler on the W-Implementation object.
-
- virtual WBool DTRemoveEventHandler( WEventID id,
- WObject * object,
- WEventHandler handler ) = 0;
-
- //
- // CallEventHandler
- //
- // Call an event handler on the W-Implementation object.
-
- virtual WBool DTCallEventHandler( WEventID id,
- WObject * object,
- WEventData * eventData=NULL,
- WLong * retval=NULL,
- WInt indexToStartAt=0 ) const = 0;
-
- //
- // DTIInterface
- //
- // Get DTInterface with a particular name. This virtual
- // function is overridden once by derived classes that use
- // DTInterfaces
-
- virtual DTIInterface * GetDTIInterface( const WChar * ifname ) = 0;
-
- //
- // Protected
- //
- // This property controls the behaviour of a design time
- // object. Protected objects are:
- // - not saved or loaded
- // - cannot be deleted directly by the user
-
- virtual WBool GetProtected() const = 0;
-
-
- /*************************************************************
- * Property Editting
- *************************************************************/
-
- //
- // EditProperties
- //
- // Display a property sheet window. Depending on "child",
- // the property sheet may be a child (as in object view) or
- // a popup dialog (normal property sheets).
-
- virtual WBool EditProperties( WWindow *,
- WBool child = FALSE ) = 0;
- //
- // ClearPropertyEditor
- //
- // Remove and destroy any open property editor for this object.
-
- virtual void ClearPropertyEditor( WBool deleteNow = FALSE ) = 0;
-
- //
- // UpdatePropertyRect
- //
- // Inform any open property editors to update the position
- // property since this object has been moved
-
- virtual WBool UpdatePropertyRect() = 0;
-
- //
- // PropDialog
- //
- // Get a pointer to the open property editor or return NULL.
-
- virtual MTPropertyDialog * GetPropDialog() = 0;
-
- //
- // HasProperty
- //
- // Return TRUE if this object has a property named "name".
-
- VEXPORT WBool HasProperty( const WString & name ) const = 0;
-
- //
- // Property
- //
- // Get or set a property with various formats.
- // The additional formats are provided for convenience only.
-
- VEXPORT WString GetProperty( const WString & name, DT_TextifyV t = 1 ) const = 0;
- VEXPORT WBool GetPropertyBool( const WString & name ) const = 0;
- VEXPORT WLong GetPropertyEnum( const WString & name ) const = 0;
- VEXPORT WRect GetPropertyRect( const WString & name ) const = 0;
- VEXPORT WLong GetPropertyLong( const WString & name ) const = 0;
- VEXPORT WBool SetProperty( const WString & name, const WString & val, DT_TextifyV t = 1 ) = 0;
- VEXPORT WBool SetPropertyBool( const WString & name, WBool val ) = 0;
- VEXPORT void SetPropertyEnum( const WString & name, WLong val ) = 0;
- VEXPORT void SetPropertyRect( const WString & name, const WRect & r ) = 0;
- VEXPORT void SetPropertyLong( const WString & name, WLong r ) = 0;
-
- //
- // MappedValue
- //
- // Deferred properties are stored internally as mapped values.
- // You can access these mapped values directly by index.
- // [ITB:REMOVE]
-
- VEXPORT WString GetMappedValue( WUInt i ) const = 0;
- VEXPORT void SetMappedValue( WUInt i, const WString & s ) = 0;
-
- //
- // PropertyChanged
- //
- // This function is called after any property has changed
- // values. You can override this function to perform
- // required actions when a property changes.
- // "name" is the name of the changed property
-
- virtual void PropertyChanged( const WString & name ) = 0;
-
- //
- // AllowUpdates
- //
- // Determine whether the DTObject should respond to
- // property changes or not. Turn this off during load;
- // if doPropertyChanged is TRUE
- // when it is re-enabled, an empty PropertyChanged is sent.
-
- virtual void SetAllowUpdates( WBool allow, WBool doPropertyChanged = TRUE ) = 0;
- virtual WBool GetAllowUpdates() const = 0;
-
- //
- // DetachEditor
- //
- // Virtual call to detach an editor if necessary.
-
- virtual void DetachEditor() = 0;
-
-
-
- /*************************************************************
- * Code Generation
- *************************************************************/
-
- //
- // ObjectPrefix
- //
- // Get the prefix used when accessing member functions of the
- // object -- eg. "cb_1->"
-
- VEXPORT WString GetObjectPrefix() const = 0;
-
- //
- // GenName
- // Generate a variable name by number, eg. cb_1 if id == 1
- // The string is an out parameter.
-
- VEXPORT void GenName( WUInt id, WString & ) const = 0;
-
- //
- // GenClassName
- //
- // Generate the name of the C++ or Java class that implements
- // this object.
-
- VEXPORT void GenClassName( WString & ) const = 0;
-
- //
- // GenResourceName
- //
- // Generate the resource ID from the object name. This is
- // usually of the form ID_name.
-
- VEXPORT void GenResourceName( WString & ) const = 0;
-
- //
- // GenResourceStyles
- //
- // Generate the .rc file styles that will be used; the first
- // parameter is a string list filled with styles, the second
- // is filled with extended styles
-
- VEXPORT void GenResourceStyles( WStringList &, WStringList & ) const = 0;
-
- //
- // GenEventObjectName
- //
- // Generate the object name for an event. The name is built
- // by recursing the DTObject hierarchy and prepending the names
- // of the DTObjects
-
- VEXPORT void GenEventObjectName( WString & ) const = 0;
-
- //
- // FindStyle
- //
- // Find a style of a given name within the object
-
- VEXPORT const MMStyle * FindStyle( const char * ) const = 0;
-
- //
- // FindProperty
- //
- // Find a property of a given name within an object
-
- VEXPORT const MMProperty * FindProperty( const char * ) const = 0;
-
-
- /*************************************************************
- * Implementation details
- *************************************************************/
- public:
- VEXPORT DTObjectImp * GetImplementation() = 0;
-
- VEXPORT void EscapeCString( WString &, const WString & ) const = 0;
- };
-
- #endif // _DTOBASE_HPP
-